package day12.handler.simpleChannelHandler.response;

import day12.packet.response.QuitGroupResponsePacket;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author chenshijie
 * @date 2024/1/2 15:42
 */
@ChannelHandler.Sharable
public class QuitGroupResponseHandler extends SimpleChannelInboundHandler<QuitGroupResponsePacket> {

    public static final QuitGroupResponseHandler INSTANCE = new QuitGroupResponseHandler();

    protected QuitGroupResponseHandler() {

    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, QuitGroupResponsePacket quitGroupResponsePacket) throws Exception {
        if (quitGroupResponsePacket.isSuccess()) {
            System.out.println("退出群【"+ quitGroupResponsePacket.getGroupId() +"】成功！");
        } else {
            System.err.println("退群失败，请稍后再试！");
        }
    }
}
